# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=asciidoc-py3
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
conflicts=("${MINGW_PACKAGE_PREFIX}-asciidoc")
provides=("${MINGW_PACKAGE_PREFIX}-asciidoc")
_ver_base=8.6.10
pkgver=8.6.10.r1390
pkgrel=1
pkgdesc="AsciiDoc is a text document format for writing notes, documentation, articles, books, ebooks, slideshows, web pages, man pages and blogs (mingw-w64)"
arch=('any')
url="https://github.com/asciidoc/asciidoc-py3"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-python3"
         "${MINGW_PACKAGE_PREFIX}-libxslt"
         "${MINGW_PACKAGE_PREFIX}-docbook-xsl")
options=('staticlibs' 'strip')
source=(git+https://github.com/asciidoc/asciidoc-py3.git
        0001-W32-confdir.mingw.patch
        0002-use-python2-in-cmd.patch)
sha256sums=('SKIP'
            'e44d1f3a98ef7e06102323843054d7443d833f421bfba55382b961fa9e4691b2'
            '0f783905233b45ab5e2450b4a4dfd621dfaab41fb5d69ea9d581c838dab22cc5')

pkgver() {
  cd ${_realname}
  printf "%s.r%s" "${_ver_base}" "$(git rev-list --count HEAD)"
}

prepare() {
  cd "${srcdir}/${_realname}"
  patch -p1 -i ${srcdir}/0001-W32-confdir.mingw.patch
  patch -p1 -i ${srcdir}/0002-use-python2-in-cmd.patch
  autoreconf -fiv
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  cp -rf ${_realname} build-${MINGW_CHOST}
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 COPYING    ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
  install -Dm644 COPYRIGHT  ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYRIGHT
}
